package www.cskaoyan.com.service.impl;

import www.cskaoyan.com.bean.Account;
import www.cskaoyan.com.dao.LoginDao;
import www.cskaoyan.com.service.LoginService;

import java.sql.SQLException;

public class LoginServiceImpl implements LoginService {

    // 调用持久层
    LoginDao loginDao;
    public LoginServiceImpl(){
        this.loginDao = new LoginDao();
    }

    /**
     * 判断账号是否存在
     * @param userAccount: 账号名
     * @return:  用户id
     */
    @Override
    public Integer checkAccount(String userAccount) throws SQLException {

        Integer id = loginDao.getIdByAccount(userAccount);

        return id;
    }

    /**
     * 判断账号是否存在
     * @param account: 账号 & 密码
     * @return:  用户id
     */
    @Override
    public Integer chackPassword(Account account) throws SQLException {

        Integer id = loginDao.getIdByAccountAndPassword(account.getUserAccount(), account.getUserPassWord());

        return id;
    }
}
